<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width,initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv=X-UA-Compatible content="IE=edge,chrome=1">
    <meta content=always name=referrer>
    <link rel="stylesheet" type="text/css" href="__STATIC__/css/base.css">
    <script src="__STATIC__/js/jquery-1.8.2.js"></script>
    <title>分销商</title>
    <style>
        .wrap-fxhy .center .main {
            background: url("__STATIC__/img_user/fx-fenxiaohuiyuan.png") no-repeat center !important;
            background-size: 100% 100% !important;
        }
    </style>
</head>
<style>
    #UL{
        position: absolute;
        background: url(__STATIC__/img_user/bg7.png);
        background-size: 100% 100%;
        width: 15%;
        padding: 2% 0 2% 0;
        text-align: center;
        display: block;
        z-index: 9;
        font-size: 12px;
        /*margin-top: -10px;*/
    }
    li>a{
        color: #A4A4A4;
    }
    .selected>a{
        color: red;
    }
</style>
{include file="public/href" /}
<body>
<!--我的钱包/分销商-->
<div class="wrap-fxhy">
    <div class="header">
        <p>分销商</p>
        <img src="__STATIC__/img/back.png" class="back" onclick=window.location.href="{:url('mobile/user_info/brokerage_index')}">
        <!--<div>
            <select onchange="change_type()" id="type" style="border: none;font-size: 16px;font-family: '微软雅黑';">

                <option value="1" {if condition="input('type') eq 1"} selected {/if}>已产生佣金</option>
                <option value="2" {if condition="input('type') eq 2"} selected {/if}>未产生佣金</option>

            </select>
        </div>-->
    </div>
    <ul class="list">
        <li {eq name=":input('level',1)" value="1"}class="cur"{/eq}><span><a href="?level=1&type={:input('type',1)}">一级({$rank.one_level})</a></span></li>
        <li {eq name=":input('level',1)" value="2"}class="cur"{/eq}><span><a href="?level=2&type={:input('type',1)}">二级({$rank.two_level})</a></span></li>
    </ul>
    <input type="hidden" id="level" value="{:input('level',1)}"  />
    <div class="center">
        <div class="cur" id="main">

        </div>
    </div>
</div>
{include file='public/src' /}
<script src="__STATIC__/js/layui/layui.js"></script>
<script>
    //layer流加载
    layui.use('flow', function() {
        var $ = layui.jquery;
        var flow = layui.flow;
        flow.load({
            elem: '#main' //流加载容器
            ,isAuto:true
            ,isLazyimg:true
            ,done: function(page, next){ //执行下一页的回调
                var lis = [];
                var level = $('#level').val();
                var type = $('#type').val();
                $.ajax({
                    url:"{:url('mobile/user_info/distribution_partner')}",
                    dataType:'json',
                    type:'post',
                    data:{'page':page,'type':type,'level':level},
                    success:function(t){
                        layui.each(t.data, function(index, item){
                            var mobile = '未设置';
                            var avatar = "/static/mobile/img_user/default_user.png";
                            var nickname = '未设置';
                            var TjNickname = '未设置';
                            if (item.avatar){
                                if (item.avatar.indexOf('http') != -1){
                                    avatar = item.avatar;
                                }else{
                                    avatar = '/'+item.avatar;
                                }

                            }
                            if (item.TjNickname){
                                TjNickname = item.TjNickname;
                            }
                            if (item.nickname){
                                nickname = item.nickname;
                            }
                            if (item.username ){
                                mobile = item.username;
                            }
                            var order_img = '';
                            if (type == 1){
                                var url = "{:url('mobile/user_info/distribution_order')}?member_id="+item.id;
                                order_img = '<div class="order"><a href="'+url+'"><img src="__STATIC__/img_user/fx-dingdan.png"><br><span>订单</span></a></div>'
                            }
                            lis.push('<div class="main" style="margin-bottom: 2%;margin-top: 0;" >' +
                                '<div class="left">' +
                                '<img src="'+avatar+'" onerror=this.src="/static/mobile/img/empty_img.png" ><br>' +
                                '<span><a href="#">'+nickname+'</a></span>' +
                                '</div>' +
                                '<div class="right">' +
                                '<div class="content" id="content" style="font-size: 12px;"><p>手机：'+mobile+'</p><p>上级：'+TjNickname+'</p>' +
                                '<p>时间：'+item.create_time+'</p><p>佣金：'+item.brokerage+'</p>' +
                                '</div>'+order_img+'' +
                                '</div>' +
                                '</div>');
                        });
                        next(lis.join(''), page < t.pages);
                    },
                    error: function () {
                        layer.open({content:'网络繁忙,请重试',skin:'msg',time:2});
                    }
                })
            }
        });
    });

    function change_type(){
        var text = $('#type').val();
        var url = "?type=2&level=1";
        if (text == 1){
            url = "?type=1&level=1";
        }
        window.location.href = url;
    }
</script>
</body>
</html>